from django.shortcuts import render
from django.shortcuts import HttpResponse

# Create your views here.
from JobCrawler.models import Job

def query(request):
    return render(request,"query.html")

def job(request):
        if(request.method == "GET"):#处理GET方法
            if(request.GET.get("queryStr") == None):
                return HttpResponse("Query string is none!")
            else:
                job = Job.objects.filter(companyName=request.GET.get("queryStr"))
                if len(job) == 0:
                    return  HttpResponse("Query Result is empty")
                else:
                    return render(request,"result.html",context=job.all()[0].__dict__)
        return HttpResponse("Do Nothing")